package dnavsim;
import java.io.File;
import java.io.IOException;

import dnavsim.bed.BEDFeature;
import dnavsim.bed.BEDFormatException;
import dnavsim.bed.BEDHandler;


public class RegionSet {

	private String name;
	
	private double freq;

	private BEDHandler bedHandler;
	
	/**
	 * Constructor.
	 * 
	 * @param name an informative name for this region set
	 * @param freq the frequency of variants in this region
	 * @param bedFile the BED file defining the region set
	 * @throws IOException 
	 * @throws BEDFormatException
	 */
	public RegionSet(String name, double freq, String bedFile) throws IOException, BEDFormatException {
		this.name = name;
		this.freq = freq;
		bedHandler = new BEDHandler(new File(bedFile));
	}

	/**
	 * Check if a feature is contained in this region set
	 * 
	 * @param chrom
	 * @param pos
	 * @return
	 */
	public boolean hasFeature(String chrom, int pos) {
		return bedHandler.hasFeature(chrom, pos);
	}

	public BEDFeature getBEDFeature(String chrom, int pos) {
		return bedHandler.getFeature(chrom, pos);
	}
	
	public BEDFeature getNextBEDFeature(String chrom, int pos) {
		return bedHandler.getNextFeature(chrom, pos);
	}
	
	public double getVariantFrequency() {
		return freq;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	
}
